﻿using System.Net;

namespace _51_C_将域名解析成IP地址
{
    internal class Program
    {
        static void Main(string[] args)
        {
            IPHostEntry hostEnter = Dns.GetHostEntry("www.baidu.com");
            if (hostEnter != null && hostEnter.AddressList != null)
            {
                foreach (IPAddress item in hostEnter.AddressList)
                {
                    Console.WriteLine(item);
                }
            }


            IPAddress[] iPAddress = Dns.GetHostAddresses("www.baidu.com");

            foreach (var ip in iPAddress)
            {
                Console.WriteLine(ip);
            }

            Console.ReadKey();
        }
    }
}
